package com.thti.mecool.client.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.thti.mecool.client.activity.R;

public class GridViewAdapter extends BaseAdapter {

	private Context mContext;

	private int[] images =
        {R.drawable.mecool_home_task_manage,R.drawable.mecool_home_plan_manage,R.drawable.mecool_home_communication_manage,R.drawable.mecool_home_work_memo,R.drawable.mecool_home_user_center
			,R.drawable.mecool_home_system_exit,R.drawable.mecool_home_sale_manage,R.drawable.mecool_home_stock_manage};
	public GridViewAdapter(Context context){
		this.mContext=context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stubs
		return 7;
	}
	
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view =((Activity) mContext).getLayoutInflater().inflate(R.layout.mecool_home_item,null);
		ImageView imageview;
		TextView showBubble;
		try {
			view.setTag(position);
			imageview=(ImageView)view.findViewById(R.id.mecool_home_item_image);
			showBubble=(TextView)view.findViewById(R.id.mecool_home_item_shownum);
			switch (position) {
			case 0:
				imageview.setImageResource(R.drawable.mecool_home_task_manage_selector);
//				showBubble.setVisibility(View.VISIBLE);
				break;
			case 1:
				imageview.setImageResource(R.drawable.mecool_home_plan_manage_selector);
				break;
			case 2:
				imageview.setImageResource(R.drawable.mecool_home_communication_manage_selector);		
				break;
			case 3:
				imageview.setImageResource(R.drawable.mecool_home_work_memo_selector);
				break;
			case 4:
				imageview.setImageResource(R.drawable.mecool_home_user_center_selector);
//				showBubble.setVisibility(View.VISIBLE);
				break;
			case 5:
				imageview.setImageResource(R.drawable.mecool_home_stock_manage_selector);
//				imageview.setImageResource(R.drawable.mecool_home_system_exit_selector);
				break;
			case 6:
//				imageview.setImageResource(R.drawable.mecool_home_sale_manage_selector);
				imageview.setImageResource(R.drawable.mecool_home_system_exit_selector);
				break;
//			case 7:
//				imageview.setImageResource(R.drawable.mecool_home_stock_manage_selector);
//				break;
			default:
				break;
			}
		} catch (Exception e) { 
			// TODO: handle exception
		}
		
		return view;
	}

}
